//package com.zmn.plat.dubbo.impl.channel;
//
//import java.util.Collections;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
//import javax.annotation.Resource;
//import javax.validation.constraints.NotNull;
//import javax.validation.constraints.Positive;
//
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.beans.BeanUtils;
//
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.collection.CollectionUtil;
//import com.zmn.common.utils.number.NumberUtil;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.common.dto.channel.ChannelServiceMasterDRO;
//import com.zmn.plat.dubbo.interfaces.channel.ChannelServiceMasterListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.manager.dictionary.ChannelDict;
//import com.zmn.plat.model.entity.channel.Channel;
//import com.zmn.plat.model.entity.channel.ChannelServiceMaster;
//import com.zmn.plat.services.interfaces.channel.ChannelService;
//import com.zmn.plat.services.interfaces.channel.ChannelServiceMasterService;
//
//import lombok.extern.log4j.Log4j2;
//
///**
// * 渠道师傅接口
// *
// * @author tanbiao
// * @since 2019 /08/29 17:41:11
// */
//@Log4j2
//@Service(loadbalance = "roundrobin", timeout = 5000, retries = -1, version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class ChannelServiceMasterListRemoteServiceImpl implements ChannelServiceMasterListRemoteService {
//    @Resource
//    ChannelServiceMasterService channelServiceMasterService;
//    @Resource
//    ChannelService channelService;
//
//    @Override
//    @ReadOnlyConnection
//    public List<ChannelServiceMasterDRO> listByChannelId(@NotNull(message = "channelId不能为空") @Positive(message = "channelId必须为大于0的正整数") Integer channelId) {
//        List<ChannelServiceMaster> channelServiceMasters = channelServiceMasterService.listByChannelId(channelId);
//        if (CollectionUtil.isNullOrEmpty(channelServiceMasters)) {
//            Channel channel = channelService.findByKey(channelId);
//            if (Objects.nonNull(channel) && Objects.equals(channel.getRank(), ChannelDict.RANK_TWO) && NumberUtil.isPositiveInteger(channel.getParentId())) {
//                channelServiceMasters = channelServiceMasterService.listByChannelId(channel.getParentId());
//            }
//        }
//
//        if (CollectionUtil.isNullOrEmpty(channelServiceMasters)) {
//            Collections.emptyList();
//        }
//
//        List<ChannelServiceMasterDRO> dros = channelServiceMasters.stream().map(channelServiceMaster -> {
//            ChannelServiceMasterDRO channelServiceMasterDRO = new ChannelServiceMasterDRO();
//            BeanUtils.copyProperties(channelServiceMaster, channelServiceMasterDRO);
//            return channelServiceMasterDRO;
//        }).collect(Collectors.toList());
//
//        return dros;
//    }
//
//    /**
//     * 批量获取渠道的白名单工程师
//     *
//     * @param channelId
//     *            the channel id
//     * @return response dto
//     */
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ChannelServiceMasterDRO>> listByChannel(Integer channelId) {
//        List<ChannelServiceMaster> channelServiceMasters = channelServiceMasterService.listByChannelId(channelId);
//        if (CollectionUtil.isNullOrEmpty(channelServiceMasters)) {
//            Channel channel = channelService.findByKey(channelId);
//            if (Objects.nonNull(channel) && Objects.equals(channel.getRank(), ChannelDict.RANK_TWO) && NumberUtil.isPositiveInteger(channel.getParentId())) {
//                channelServiceMasters = channelServiceMasterService.listByChannelId(channel.getParentId());
//            }
//        }
//
//        if (CollectionUtil.isNullOrEmpty(channelServiceMasters)) {
//            return ResponseDTO.fail("对应渠道未配置工程师");
//        }
//
//        List<ChannelServiceMasterDRO> dros = channelServiceMasters.stream().map(channelServiceMaster -> {
//            ChannelServiceMasterDRO channelServiceMasterDRO = new ChannelServiceMasterDRO();
//            BeanUtils.copyProperties(channelServiceMaster, channelServiceMasterDRO);
//            return channelServiceMasterDRO;
//        }).collect(Collectors.toList());
//
//        return ResponseDTO.success(dros);
//    }
//
//}
